{% extends "Base.html" %}

{% block title %}tistory4mp3{% if hasQuery %} - {{ origQuery }}{% endif %} {% endblock %}

{% block script %}
  {% if hasQuery %}
    <script type="text/javascript" src="http://jqueryjs.googlecode.com/files/jquery-1.3.1.js"></script>
    <script type="text/javascript">
    <!-- 
      $(document).ready(
        function onPageLoad() {
        	{% for blogUrl in blogUrls reversed %}
            function lastAddedLiveFunc{{ blogUrl.num }}() {
                $.get("/TistoryMp3List?blogUrl={{ blogUrl.blogUrl }}&num={{ blogUrl.num }}", 
                  function(data) {
                    if(data != "") {
                      $(".TistoryMp3List:last").after(data);
                    }
                    {% ifequal end blogUrl.num %}
                      $('div#lastPostsLoader').empty();
                    {% endifequal %}
                  }
                );
                
                {% ifnotequal end blogUrl.num %}
                  lastAddedLiveFunc{{ blogUrl.num|add:"1" }}();
                {% endifnotequal %}
              };
              {% endfor %}
              
            $('div#lastPostsLoader').html('<img src="/images/bigLoader.gif">');
            lastAddedLiveFunc1();
          }
        );
    // -->
    </script>
  {% endif %}
{% endblock %}

{% block body %}    
  <h1>
    Enter Keywords related Mp3 Files that You Want.<br/>
    (ex: Jason Mraz, 쇼팽, 윤종신, SMAP, 한국인이 좋아하는 락, etc...)
  </h1>
  <form name="searchForm" action="/" method="get">
    <div>
      Query: <input name="query" size="50" value="{{ origQuery }}"/>
      <input type="submit" value="Search!" />
    </div>
  </form>
  
  <script type="text/javascript">
    <!-- 
    document.searchForm.query.focus();
    -->
  </script>
  
  {% if hasQuery %}
    {{ search_results }}
    
    {% block adsense %}
      <div class="adsense">
        <script type="text/javascript"><!--
          google_ad_client = "pub-5747261949828262";
          /* tistory4mp3 main, 728x90 */
          google_ad_slot = "6897642845";
          google_ad_width = 728;
          google_ad_height = 90;
          //-->
        </script>
        <script type="text/javascript"
          src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
        </script>
      </div>
    {% endblock %}
    
  {% else %}
    <div class="adsense_bottom">
      <script type="text/javascript"><!--
        google_ad_client = "pub-5747261949828262";
        /* tistory4mp3 between contents, 468x15 */
        google_ad_slot = "0252822775";
        google_ad_width = 468;
        google_ad_height = 15;
        //-->
      </script>
      <script type="text/javascript"
        src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
      </script>
    </div>
  {% endif %}
  
  <div class="TistoryMp3List" id="0" />
    
  <div id="lastPostsLoader" />
  
{% endblock %}